package Task40;

import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner in=new Scanner(System.in);
        while(in.hasNext()){
            String s1=in.next();
            String s2=in.next();
            int[] dp=new int[s2.length()+1];
            for(int i=0;i<s1.length();i++){
                int pre=dp[0];
                for(int j=1;j<=s2.length();j++){
                    int temp=dp[j];
                    if(s1.charAt(i)==s2.charAt(j-1))
                        dp[j]=Math.max(dp[j],Math.max(dp[j-1],pre+1));
                    else
                        dp[j]=Math.max(dp[j],Math.max(dp[j-1],pre));
                    pre=temp;
                }
            }
            System.out.println(dp[s2.length()]);
        }
        in.close();
    }
}
//    abcfbc abfcab
//    programming contest
//    abcd mnp
